using Commons.Models.Definitions;
using Commons.Models.Scores;
using Commons.Models.Settings.Dtos.Scores;
using Commons.Models.Settings.Mappers.Matchers;

namespace Commons.Models.Settings.Mappers.Scores
{
	public class HighScoreDefinitionMapper : IMapper<HighScoreDefinitionDto, HighScoreDefinition>
	{
		public HighScoreDefinition Map(HighScoreDefinitionDto config)
		{
			int code = config.Code;
			string name = config.Name;
			Periodicity periodicity = Periodicity.GetByName(config.Periodicity);

			HighScoreDefinition highScore = new HighScoreDefinition(code, name, periodicity);
			highScore.Matcher = new MatcherMapper().Map(config.Matcher);
			return highScore;
		}
	}
}

